package com.chainyoung.component_tmperson.ui.mvp.presenter;

import com.chainyoung.common.appcommon.entity.CommonList;
import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.di.scope.ActivityScope;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.R2;
import com.chainyoung.component_tmperson.entity.Purse;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletContact;
import com.chainyoung.component_tmperson.ui.mvp.contract.WithDrawContact;

import java.util.TreeMap;

import javax.inject.Inject;

@ActivityScope
public class WithDrawPresenter extends BasePresenter<WithDrawContact.Model, WithDrawContact.View> {


    @Inject
    public WithDrawPresenter(WithDrawContact.Model model, WithDrawContact.View rootView) {
        super(model, rootView);
    }


    public void withDraw(TreeMap<String, Object> map) {
        addSubscribe(mModel.withDraw(map)
                .compose(RxUtils.<String>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<String>(mView,true) {
                    @Override
                    public void onNext(String data) {
                        mView.onWithDrawSuccess(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }

    public void sendCode(TreeMap<String, Object> map) {

        addSubscribe(mModel.getSendCode(map)
                .compose(RxUtils.<String>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<String>(mView,true) {
                    @Override
                    public void onNext(String object) {
                        mView.onSendCodeSuccess(object);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }


}
